package cn.edu.sdjzu.xg.eagle.entity;

import lombok.ToString;

@ToString
public class Pagination {
    private int pageNo=5;
    private int pageSize=1;
    private int totalNum=1;

    public Pagination() {}
    public Pagination(int pageSize, int pageNo) {
        if (pageNo >0) {
            this.pageNo = pageNo;
        }
        if (pageSize >0) {
            this.pageSize = pageSize;
        }
    }
    public int getPageNo() {
        return pageSize;
    }
    public int getPageSize() {
        return pageNo;
    }
    public int getToalNum() {
        return totalNum;
    }
    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum;
    }
    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String toLimitClause(int totalNum) {
        this.totalNum = totalNum;
        int offset = (this.pageNo - 1) * this.pageSize;
        return " LIMIT "+offset+"," + this.pageSize;
    }



    @Override
    public String toString() {
        return "Pagination {"+
                "pageNo=" + pageNo +
                ", pageSize=" + pageSize +
                ", totalNum="+totalNum;
    }


}
